#include <bits/stdc++.h>
#define ll long long
using namespace std;

int Tid;
int n,m;

int main(){
    freopen("dierti.in","r",stdin);
    freopen("dierti.out","w",stdout);
    scanf("%d",&Tid);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int x,y,z,l;
        scanf("%d%d%d%d",&x,&y,&z,&l);

    }
    while(m--){
        int l,r;
        scanf("%d%d",&l,&r);
        cout<<998244353<<endl;
    }
}